package com.wms.controller;

import com.wms.bean.PageBean;
import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.dto.BtransfersentDTO;
import com.wms.dto.SuserUpVo;
import com.wms.dto.SuserVo;
import com.wms.entity.Btransfersent;
import com.wms.entity.Suser;
import com.wms.service.BtransfersentService;
import com.wms.service.SuserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/btransfersent")
@Api(tags = "调出配发--张开心")
@Slf4j
public class BtransfersentController {

    @Autowired
    private BtransfersentService btransfersentService;
    @PostMapping("/query")
    @ApiOperation(value = "分页查询库管员列表和条件查询")
    public ResultBean<PageBean<List<Btransfersent>>> queryPage(@ApiParam(value = "库管员查询条件") @RequestBody BtransfersentDTO btransfersentDTO) {
        log.info("分页查询库管员列表: 页码={}, 每页条数={}, 条件={}", btransfersentDTO);
        PageBean<List<Btransfersent>> pageBean = btransfersentService.selectBtran(btransfersentDTO);
        return R.success("分页查询成功", pageBean);
    }


    @PostMapping("/insert")
    @ApiOperation(value = "新增发配信息")
    public ResultBean<Integer> insert(
            @ApiParam(value = "新增发配信息", required = true) @RequestBody Btransfersent btransfersent) {
        log.info("新增发配信息: {}", btransfersent);
        int rows = btransfersentService.insert(btransfersent);
        return rows==1?R.success("新增成功", rows):R.fail("新增失败");
    }
}
